package com.sean.findme;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import android.app.ActivityGroup;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class FmCtrllerBase {
	
	public static void JmpActivity( Context context, Class<?> cls, ActivityGroup group, HashMap<String,String> map )
	{
		LinearLayout container = (LinearLayout)group.getWindow()
			.findViewById(R.id.group_activity_layout);
		container.removeAllViews();
		Intent intent = new Intent(context,cls);
		intent.putExtra("clsFrom", context.getClass().getName() );
		if( map != null )
		{
			Iterator iter = map.entrySet().iterator();
			while( iter.hasNext() )
			{
				Map.Entry entry = (Map.Entry)iter.next();
				String key = (String)entry.getKey();
				String value = (String)entry.getValue();
			
				intent.putExtra(key, value);
			}
		}
		
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		Window subActivity = group.getLocalActivityManager()
			.startActivity("NearMapActivity", intent);
		View view = subActivity.getDecorView();	
		container.addView(view);
	
		LinearLayout.LayoutParams params = (LayoutParams)view.getLayoutParams();
		params.width = LayoutParams.FILL_PARENT;
		params.height = LayoutParams.FILL_PARENT;
		view.setLayoutParams(params);
	}

}
